/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.startingbsd.dao;

import br.com.startingbsd.util.JPAUtil;
import javax.persistence.EntityManager;

/**
 *
 * @author Felipe
 */
public class BaseDAO {

    public static EntityManager getEntityManager() {
        return JPAUtil.getEmf().createEntityManager();
    }

    public static void insert(Object object) {
        EntityManager em = getEntityManager();
        em.getTransaction().begin();
        em.persist(object);
        em.getTransaction().commit();
        em.close();
    }

    public static void update(Object object) {
        EntityManager em = getEntityManager();
        em.getTransaction().begin();
        em.merge(object);
        em.getTransaction().commit();
        em.close();
    }
}
